package leetcode_zh

func getMax(nums ...int) int {
	var max = nums[0]
	for i := 1; i < len(nums); i++ {
		if max < nums[i] {
			max = nums[i]
		}
	}
	return max
}

func getMin(nums ...int) int {
	var min = nums[0]
	for i := 1; i < len(nums); i++ {
		if min > nums[i] {
			min = nums[i]
		}
	}
	return min
}

type ListNode struct {
	Val  int
	Next *ListNode
}

func (receiver ListNode) buildListNode(vals []int) *ListNode {
	if len(vals) <= 0 {
		return nil
	}
	dumpHead := &ListNode{}
	preNode := dumpHead
	for i := 0; i < len(vals); i++ {
		preNode.Next = &ListNode{
			Val: vals[i],
		}
		preNode = preNode.Next
	}
	return dumpHead.Next
}

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}
